﻿using System;
using SCG = System.Collections.Generic;

using Nemerle;
using Nemerle.Assertions;
using Nemerle.Collections;
using Nemerle.Compiler;
using Nemerle.Utility;
using PT = Nemerle.Compiler.Parsetree;
using TT = Nemerle.Compiler.Typedtree;

namespace Nemerle.OpenCL {

    [MacroUsage(MacroPhase.BeforeInheritance, MacroTargets.Class)]
    macro EqualityByIdPattern(tb : TypeBuilder) {
        def ty = <[ $(FixedType.Class(tb, []) : typed) ]>;
        tb.Define(<[ decl:
            public override Equals(_ : object) : bool {
                | null => false
                | other is $ty => this.Id.Equals(other.Id)
                | _ => false
            }
        ]>);
        tb.Define(<[ decl:
            public override GetHashCode() : int {
                this.Id.GetHashCode()
            }
        ]>);
    }

}